package com.lu.dog.dbrowser.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.Toolbar;
import android.text.format.DateFormat;

import com.lu.adog.base.BaseActivity;
import com.lu.adog.base.BaseConfig;
import com.lu.dog.dbrowser.R;
import com.lu.dog.dbrowser.bean.LogInfo;
import com.lu.dog.dbrowser.db.DBrowserDbHelper;

public class LogDesActivity extends BaseActivity {
    private Toolbar toolbar;
    private LinearLayoutCompat lcTitleBar;
    private AppCompatTextView tvTitleLogdes;
    private AppCompatTextView tvTimeLogdes;
    private AppCompatEditText etLogdes;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logdes);

        assignViews();

    }

    private void assignViews() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        lcTitleBar = (LinearLayoutCompat) findViewById(R.id.lc_title_bar);
        tvTitleLogdes = (AppCompatTextView) findViewById(R.id.tv_title_logdes);
        tvTimeLogdes = (AppCompatTextView) findViewById(R.id.tv_time_logdes);
        etLogdes = (AppCompatEditText) findViewById(R.id.et_logdes);

        Intent intent = getIntent();
        int logInfoId = intent.getIntExtra(BaseConfig.KEY_LOG_ID, -1);
        if (logInfoId == -1) {
            return;
        }
        LogInfo logInfo = DBrowserDbHelper.getInstance(LogDesActivity.this).selectLogInfoById(logInfoId);
        etLogdes.setText(logInfo.getContent());
        tvTitleLogdes.setText(logInfo.getTitle());
        tvTimeLogdes.setText(DateFormat.format("yyyy-MM-dd hh:mm:ss", logInfo.getCreateTime()));

    }


}
